package com.dcits.idea.util;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.ui.Messages;
import com.intellij.util.messages.impl.Message;
import org.nustaq.serialization.coders.JSONAsString;


import java.util.HashMap;
import java.util.Map;

/**
 * @Author tangmqb DCITS
 * @DATE 2021/11/4 16:47
 * @Version 1.0.0
 */
public class WebRequest {

    public static String DUTNAG_URL = "https://api.nextrt.com/V1/Dutang";

    public static String getDuTang(){
        String result = HttpClientUtil.doGet(DUTNAG_URL);
        System.out.println("鸡汤接口返回:"+result);
        String res = null;
        try {
            res = result.substring(result.lastIndexOf("\"content\":") + 11, result.lastIndexOf("\"}]"));
        } catch (Exception e) {
            Messages.showMessageDialog("鸡汤接口出错","请求结果",null);
        }
        if (null == res || "".equals(res)) {
            res = "接口返回报文:\n"+result;
        }
        return res ;
    }
}
